package Bank;

/**
 * @Author czl
 * @Date 2024-03-21
 */
public class Account {
    private double money;

    public Account(){

    }

    public Account(double money){
        this.money=money;
    }

    public synchronized void getMoney(String name , double money){
        System.out.println(name + "取了" + money + "元");

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (this.money > money){
            this.money=this.money-money;
            System.out.println("余额还剩" + this.money + "元");
            return;
        }else{
            System.out.println("余额不足" + "余额还剩" + this.money + "元");
        }
    }
}
